//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <cstdlib>

#include <iostream>
#include <fstream>

#include "ManipulateMatrix.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main(int argc, char** argv) {

  String* filenameMatrix;
  String* filenameList;
  String* filenameOut;

  if (argc < 4) {
    cout << "Error in the input arguments. The execution must be: " << endl;
    cout << "./OrderMatrixValue <Path of Matrix File> <Path of File with Ordered List> <Output Ordered Matrix File>" << endl;
    return 0;
  }
  else {
    cout << "---------------------------------------------------------------------------------" << endl;
    cout << "            Path of Matrix File : " << argv[1] << endl;
    cout << " Path of File with Ordered List : " << argv[2] << endl;
    cout << "     Output Ordered Matrix File : " << argv[3] << endl;
    cout << "---------------------------------------------------------------------------------" << endl;
    filenameMatrix  = new String(argv[1]);
    filenameList = new String(argv[2]);
    filenameOut  = new String(argv[3]);
  }

  ManipulateMatrix* manipulateMatrix = new ManipulateMatrix();

  manipulateMatrix->FilenameMatrix(filenameMatrix);
  manipulateMatrix->FilenameList(filenameList);
  manipulateMatrix->FilenameOut(filenameOut);
  manipulateMatrix->LoadData();
  manipulateMatrix->WriteOriginalMatrix();
  manipulateMatrix->OrderMatrixByList();
  manipulateMatrix->WriteResultedMatrix();

  cout << "---------------------------------------------------------------------------------" << endl;

  if (manipulateMatrix) delete manipulateMatrix;

  return 1;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//


